/*
 * etch-a-sketch.h
 *
 *  Created on: Jun 6, 2011
 *      Author: David Tanner
 */

#ifndef ETCH_A_SKETCH_H_
#define ETCH_A_SKETCH_H_


#define myCLOCK	8000000					// clock speed
#define WDT_CLK	32000					// 32 Khz WD clock (@1 Mhz)
#define	WDT_CTL	WDT_MDLY_32				// WDT SMCLK, ~32ms
#define	WDT_CPS	myCLOCK/WDT_CLK			// WD clocks / second count
#define THRESHOLDX 6					// a number must change by at least 6
#define THRESHOLDY 10					// a number must change by at least 6
#define TIMEOUT 5						// go to sleep after 5 seconds of nothing
#define SAMPLES 10


#define ticks 1024						// We have 10 bits of precision

#define xPixels	160.0						// so many pixels on the X domain
#define yPixels	100.0						// so many pixels in the Y domain

#define scaleX(x) x*xPixels/ticks;
#define scaleY(y) y*yPixels/ticks;


int locationChanger(double rawdouble);
void calcX(void);
void calcY(void);
void drawPoints(void);
int drawX(int x);
int drawY(int y);
void buttonPush(void);
void readFromFRAM(void);
void saveToFRAM(void);
void clearScreen(void);
void waitForMovement(void);



#endif /* ETCH_A_SKETCH_H_ */
